﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
using WindowsFormsApplication1.WebTest;
using WindowsFormsApplication1.WebTest.WebTestXmlNodes;

namespace WindowsFormsApplication1
{
    public class WebTestTreeView : TreeView
    {
        public void LoadWebTest(string webTestPath)
        {
            StreamReader sr = new StreamReader(webTestPath);
            XmlReader xr = XmlReader.Create(sr);

            Nodes.Clear();


            XmlSerializer webTestSerializer = new XmlSerializer(typeof(WebTestNode));
            xr.MoveToContent();

            try
            {
                WebTestNode webTestNode = (WebTestNode)webTestSerializer.Deserialize(xr);
                Nodes.Add(webTestNode);
            }
            catch (Exception exc)
            {
                Notification.FailOperation(exc, NodeOperationEventArgs.EventImportance.Error);
            }
            finally
            {
                xr.Close();
                sr.Close();
            }

        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            this.ResumeLayout(false);

        }

        
    }
}
